﻿using Lambda3.VisualStudio.DataTools.Generators.Cpf;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Microsoft.Data.Schema.Tools.DataGenerator;

namespace Lambda3.VisualStudio.DataTools.Generators.Tests
{
    [TestClass]
    public class DataGeneratorTest
    {
        #region Test Settings

        /// <summary>
        ///Gets or sets the test context which provides
        ///information about and functionality for the current test run.
        ///</summary>
        public TestContext TestContext { get; set; }

        // 
        //You can use the following additional attributes as you write your tests:
        //
        //Use ClassInitialize to run code before running the first test in the class
        //[ClassInitialize()]
        //public static void MyClassInitialize(TestContext testContext)
        //{
        //}
        //
        //Use ClassCleanup to run code after all tests in a class have run
        //[ClassCleanup()]
        //public static void MyClassCleanup()
        //{
        //}
        //
        //Use TestInitialize to run code before running each test
        //[TestInitialize()]
        //public void MyTestInitialize()
        //{
        //}
        //
        //Use TestCleanup to run code after each test has run
        //[TestCleanup()]
        //public void MyTestCleanup()
        //{
        //}
        //
        #endregion

        [TestMethod]
        public void Generate_Same_Random_Cpf_From_Constant_Seed()
        {
            var generator = GetGenerator();

            generator.GenerateNextValues();

            Assert.AreEqual("248.668.583-97", generator.Output);
        }

        [TestMethod]
        public void Generate_New_Random_Cpf_Each_Time()
        {
            var generator = GetGenerator();

            generator.GenerateNextValues();
            Assert.AreEqual("248.668.583-97", generator.Output);
            string lastCpf = generator.Output;

            generator.GenerateNextValues();
            Assert.AreNotEqual(lastCpf, generator.Output);
            lastCpf = generator.Output;

            generator.GenerateNextValues();
            Assert.AreNotEqual(lastCpf, generator.Output);
        }

        private static CpfDataGenerator GetGenerator()
        {
            var generator = new CpfDataGenerator {Seed = 1, IncludeDigitSeparator = true, IncludeGroupSeparator = true};
            generator.Initialize(new GeneratorInit());

            return generator;
        }
    }
}
